package app;

import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.menhoo.toollibrary.common.utils.BitmapUtil;
import com.lidroid.xutils.util.LogUtils;

import application.AppApplication;
import application.HttpUrlConstant;
import application.KeyConstant;
import mainUI.AppActivity;
import menhoo.com.i8officelibrary.R;

/**
 * Created by yanglei on 16/1/21.
 */

public class About extends AppActivity {

    ImageView AppIconTitle;

    ImageView AppIconBackground;

    TextView AppDesc;

    ImageView titlebar_btn_back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.about);
        try {
            AppIconTitle = (ImageView) findViewById(R.id.AppIconTitle);
            AppIconBackground = (ImageView) findViewById(R.id.AppIconBackground);
            AppDesc = (TextView) findViewById(R.id.AppDesc);
            titlebar_btn_back = (ImageView) findViewById(R.id.titlebar_btn_back);

            titlebar_btn_back.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onBackPressed();
                }
            });
        } catch (Exception e) {
            LogUtils.e(e.getMessage() + "");
        }
        setStatusBarVisible(View.GONE);

        setTitle("关于");
        setTitleDisplay(false);
        //textView.setText("阿里云推送TokenID="+AppApplication.getALiYunDeviceId());

        try {
//            Intent it = new Intent(About.this, IMtest.class);
//            startActivity(it);
//            //MessageUtil.showShortToast(this,"获得的数据是："+getIntent().getDataString());

            initImage();
        } catch (Exception e) {
        }
    }

    void initImage() {
        try {

            String AppIconTitleVal = AppApplication.getAppKeyValueSet().readAppSetPreferences(KeyConstant.AppIconTitle);
            String AppIconBackgroundVal = AppApplication.getAppKeyValueSet().readAppSetPreferences(KeyConstant.AppIconBackground);

            if (AppIconTitleVal.equalsIgnoreCase("app_icon_title.png")) {
                AppIconTitle.setImageBitmap(BitmapUtil.getRoundedCornerBitmap(BitmapFactory.decodeStream(this.getResources()
                        .openRawResource(R.raw.ic_launcher)), 15f));
            } else {
                getIconLoader().display(AppIconTitle, HttpUrlConstant.getWebSiteFullUrl(AppIconTitleVal));
            }
            if (AppIconBackgroundVal.equalsIgnoreCase("app_icon_background.png")) {
                AppIconBackground.setImageBitmap(BitmapFactory.decodeStream(this.getResources().openRawResource(R.raw
                        .app_icon_background)));
            } else {
                getIconLoader().display(AppIconBackground, HttpUrlConstant.getWebSiteFullUrl(AppIconBackgroundVal));
            }


        } catch (Exception e) {
            LogUtils.e(e.getMessage() + "");
        }
    }
}
